package cn.com.bluemoon.daps.system.controller.api;


import cn.com.bluemoon.daps.api.sys.RemoteDapNoticeInfoService;
import cn.com.bluemoon.daps.common.constant.ServiceNameConstants.DapsApiSystem;
import cn.com.bluemoon.daps.common.datascope.BmPermission;
import cn.com.bluemoon.daps.common.datascope.IgnorePermission;
import cn.com.bluemoon.daps.common.datascope.log.holder.ProcessLogHolder;
import cn.com.bluemoon.daps.common.domain.ResultBean;
import cn.com.bluemoon.daps.common.domain.UserInfoHolder;
import cn.com.bluemoon.daps.system.controller.DapNoticeController;
import cn.com.bluemoon.daps.system.dto.NoticeSendRequestDto;
import cn.com.bluemoon.daps.system.service.DapNoticeInfoService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@Api(tags = {"FeignClient服务-消息通知api接口"})
@RequestMapping(DapsApiSystem.API_SYS_NOTICE)
@RestController
@Slf4j
public class DapNoticeInfoServiceApi implements RemoteDapNoticeInfoService {
    @Autowired
    private DapNoticeController noticeController;

    @Override
    @BmPermission(value = "", ignore = true)
    public ResultBean<Boolean> send(@Valid @RequestBody NoticeSendRequestDto sendRequestDto) {
        UserInfoHolder.UserInfo userInfo = UserInfoHolder.getUserInfoOrEmpty();
        // 发送
        ProcessLogHolder.append("用户" + userInfo.getAccount() + "发送消息");
        Boolean res = noticeController.doSend(sendRequestDto, userInfo);
        return ResultBean.ok(res);
    }
}
